package misc;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

public final class Hashing {

  private Hashing() {
  }

  public static byte[] get128bitsFromSHA_512(String text) {
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA-512");
      digest.update(text.getBytes());

      byte[] d = digest.digest();
      byte[] _128bits = Arrays.copyOf(d, 16);
      return _128bits;

    } catch (NoSuchAlgorithmException ex) {
      ex.printStackTrace();
      System.exit(-1);
      return null; // um den java compiler zu befridigen
    }

  }

  public static byte[] getSHAValue128(char[] text) {
    return get128bitsFromSHA_512(new String(text));
  }
}
